package com.go8.mall.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

@Configuration
@ConfigurationProperties("ali.pay")
public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2016101800714066";
	
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCz+bKEKE664aXQIXlkuk5H4vJw5v5cBiKdRLI3lfMS8BVVGoRPiyEV2ZpNCKUEOOst75OE2xB6ect4foCTIxSADk1N4+9J2FpDJPoLgWp9pEFntldSvpHUhKAoYxMGioWqACPVccO9lYbA4nYzBwiicjvpALMEHJxgpEavNYd8Dlw76hhC/iSX3LH9uGq7AOy5JekeQcdaSGp4fNVo/98uS4h1b8MgiIorSBUqDu8PrmSNtv5FJt+h4v9HfHdlIQeJpuqyiI14qDu9dYdzS4jg15MLeJ2fdNWPeigJ0MnjlYHpfnpZyafPnw+8d6CrB5EMdp/pLZGC0nTXz6xRcVxDAgMBAAECggEAY7UuZXE/TOG+TzR8YIWm4MSmtE4FFU6A1sg8Q/dbF17TMrbiHn9h8Q0BIzRq15ABGw3jmHMVCgV36GWNLfb9YISL518kLrEiMJjHvqAQM1NQuPiYIEtb13Uyla1t2O3dZ3V0ZMgGPX4djbbo7RQ0gGrxLgEpLFn9eL0KO/9X9C3BH4m9iwTSdP4D/Y6mGbgnkmQGoGni7ZZ0zG3pbHlYVi3mjakI3XFCFUicqQlh11P5v07nHt9bhRcsTrgJWu+IhATc27rS5zyjki1HtNb7qml0nh7eULeGRU2YnPTuzD3+rhMwXFVrmf0kYZN2S0b+lycXZuRGWJJWhIgwLZzPIQKBgQDwoT6EoK15eJ6UKKZlOYHRXba4PLZ2Dub//YQD6mIAQ6hjPjYycMgxmk7Gsz3bsqDrnq5im9IYuhch5xfTtGfShWsZ8OJREPllIUoceLn/zwlBqz6sDzfvJ+2V5SrSvNfg96weX69BT/OZk30mTSD3B+c9qonEcFy4nzs6yjcWjQKBgQC/eKMUde9UNyCb7n20G+SSnD9+A3gPN9qsM5lPNRmJLqz7rPKdz82pRAt73A02cXV6YIv2EXfJ1d5MvMjClHxgc9odEeryzvdULcbGmIsob4uYl4IVjbb/o/YQuqZj5Pcke856cJJu9rz8ufGYTJppaJzudO7ltzfHgp9L8u2yDwKBgQCJ+FpJX3u3/3Ilj11BAwUtT6d54c3YyVioBOtR92zzq9d79+rJZyNSVaC/i3x3YOel0dk5TxDa/rBOzxs5VuKEsd0kBZsuUiY9VyYQRySWyVYMYizQKPWwWdt/K+Qu6vp40mnNDJ4HO9l4ADos4OJ64fwzvnm5uZdggGRMpC+L7QKBgQC5sf43sclTG8P8duhi7UpZBkBtrl+aIslpiQF+2DjT2vjZfXovo4IKT3vzvA70ZkVRUqFrHLXYghr+wXjTfb7CrJk06FO8+QzWDy9hHECaDtSMQSRgUvjQJexXfS4yY7VtJMWz6cma5KGVWaD93A1Ffbf1bGLlVzQ5wm1L82aj8QKBgQCu47A4DeZu15RtIrr29fs0prrMBSRRGtEzzFvgKh9HAe6Y7UrFqNYRY0TfIVYVWyuLxg6V7y0jkSUucZhfAaAXujHSVp7dCb268/mgywTXpg3GZJbGC1Jdz60wSdPovKwXTyp55NuE8hE4qcQuZmJ2JGg04fMrP7VeTVGqpwrHxg==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiDeeUOZXuo6ybey6iHukZwa4IoYiZkWZnYyGL+n3cUPj2Ydcffvelb1F1eK/hwN3H4b2dUF7KUyFb1srHZS76qr2ej+04q9blUayVQ0vNwNVjCZEMqRuC17O+xSiGsgXJlI2bS4BQUNrD9qfNECBzc1UMnNRlAgejUfMc+NPdXKil7XjFKgmARhrSZGvjbOpXrQlJ8tO9TBjsy342CEuyEVv0tpqHDaWV7NzqjIG6lGOAqemU5Puh0QLGmXXwDNjsBOZn1wyzqVPcriDwJCGhXl5jRs68iz0hw70fr88k/32PH0mmNgdA0bcEW5vl5w9C1LfWnXCnZ8QGo/vs85y3QIDAQAB";
    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问

    //http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp
	//public static String notify_url = "http://localhost:8889/alipay/notify_url";
	private String notify_url;

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	//public static String return_url = "http://localhost:8889/alipay/return_url";
	private String return_url;

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	//public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";https://openapi.alipaydev.com/gateway.do
	private String gatewayUrl;
	
	// 支付宝网关
	//public static String log_path = "C:\\";
	private static String log_path = "/go8/mall/logs";

    public String getNotify_url() {
        return notify_url;
    }

    public void setNotify_url(String notify_url) {
        this.notify_url = notify_url;
    }

    public String getReturn_url() {
        return return_url;
    }

    public void setReturn_url(String return_url) {
        this.return_url = return_url;
    }

    public String getGatewayUrl() {
        return gatewayUrl;
    }

    public void setGatewayUrl(String gatewayUrl) {
        this.gatewayUrl = gatewayUrl;
    }
//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

